package model.dao;

import java.io.IOException;
import java.io.Reader;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class SqlMapFactory {
	private SqlMapClient client;
	private static SqlMapFactory instance = new SqlMapFactory();
	
	private SqlMapFactory(){
		try {
			Reader reader = Resources.getResourceAsReader("config/SqlMapConfig.xml");
			System.out.println("reader : "+reader);
			client = SqlMapClientBuilder.buildSqlMapClient(reader);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	
	public static SqlMapFactory getInstance(){
		if(instance==null){
			instance = new SqlMapFactory();
		}
		return instance;
	}
	
	public SqlMapClient getClient(){
		return client;
	}
}
